import React, { Component } from 'react';
import classnames from 'classnames'; // cnpm i classnames -S
class App extends Component {
  render() {
    // btn-success btn-danger type
    // btn-sm btn-md btn-lg size
    const type = 'success'
    const size = 'md'
    let str = 'btn'
    type === 'success' ? str += ' btn-success' : (type === 'danger' ? str += ' btn-danger' : str += '')
    size === 'sm' ? str += ' btn-sm' : ( size === 'md' ? str += ' btn-md' : (size === 'lg' ? str += ' btn-lg' : str += ''))
    return (
      <div>
        <button className={ str }>按钮-字符串拼接</button>
        <button className={ classnames({
          btn: true,
          'btn-success': type === 'success',
          'btn-danger': type === 'danger',
          'btn-sm': size === 'sm',
          'btn-md': size === 'md',
          'btn-lg': size === 'lg'
        }) }>按钮-classnames</button>
      </div>
    );
  }
}

export default App;